Mirah (programming Language)
   HOME

TheInfoList



OR:

Mirah (formerly Duby) has been a
programming language A programming language is a system of notation for writing computer programs. Most programming languages are text-based formal languages, but they may also be graphical. They are a kind of computer language. The description of a programming ...
based on
Ruby A ruby is a pinkish red to blood-red colored gemstone, a variety of the mineral corundum ( aluminium oxide). Ruby is one of the most popular traditional jewelry gems and is very durable. Other varieties of gem-quality corundum are called sa ...
language syntax, local
type inference Type inference refers to the automatic detection of the type of an expression in a formal language. These include programming languages and mathematical type systems, but also natural languages in some branches of computer science and linguistics ...
, hybrid static–dynamic
type system In computer programming, a type system is a logical system comprising a set of rules that assigns a property called a type to every "term" (a word, phrase, or other set of symbols). Usually the terms are various constructs of a computer progra ...
, and a pluggable compiler
toolchain In software, a toolchain is a set of programming tools that is used to perform a complex software development task or to create a software product, which is typically another computer program or a set of related programs. In general, the tools form ...
. Mirah was created by Charles Oliver Nutter to be "a 'Ruby-like' language, probably a subset of Ruby syntax, that
ould Ould is an English surname and an Arabic name ( ar, ولد). In some Arabic dialects, particularly Hassaniya Arabic, ولد‎ (the patronymic, meaning "son of") is transliterated as Ould. Most Mauritanians have patronymic surnames. Notable p ...
compile to solid, fast, idiomatic
JVM A Java virtual machine (JVM) is a virtual machine that enables a computer to run Java programs as well as programs written in other languages that are also compiled to Java bytecode. The JVM is detailed by a specification that formally describes ...
bytecode Bytecode (also called portable code or p-code) is a form of instruction set designed for efficient execution by a software interpreter. Unlike human-readable source code, bytecodes are compact numeric codes, constants, and references (norma ...
." The word ' refers to the gemstone
ruby A ruby is a pinkish red to blood-red colored gemstone, a variety of the mineral corundum ( aluminium oxide). Ruby is one of the most popular traditional jewelry gems and is very durable. Other varieties of gem-quality corundum are called sa ...
in the
Javanese language Javanese (, , ; , Aksara Jawa: , Pegon: , IPA: ) is a Malayo-Polynesian language spoken by the Javanese people from the central and eastern parts of the island of Java, Indonesia. There are also pockets of Javanese speakers on the northe ...
, a play on the concept of Ruby in Java.


History

To foster more participation in the
JRuby JRuby is an implementation of the Ruby programming language atop the Java Virtual Machine, written largely in Java. It is free software released under a three-way EPL/GPL/LGPL license. JRuby is tightly integrated with Java to allow the embedding ...
project from Ruby community members, Nutter began to explore the possibility of presenting Ruby syntax, but with a
static type In computer programming, a type system is a logical system comprising a set of rules that assigns a property called a type to every "term" (a word, phrase, or other set of symbols). Usually the terms are various constructs of a computer progra ...
model and direct-to-native compiling. In this context, "native" meant mainly the
Java virtual machine A Java virtual machine (JVM) is a virtual machine that enables a computer to run Java programs as well as programs written in other languages that are also compiled to Java bytecode. The JVM is detailed by a specification that formally describes ...
(JVM), but Mirah has been designed around the possibility of having alternative backends for other object-oriented runtimes like the
Common Language Runtime The Common Language Runtime (CLR), the virtual machine component of Microsoft .NET Framework, manages the execution of .NET programs. Just-in-time compilation converts the managed code (compiled intermediate language code) into machine instructio ...
(CLR) of the
.NET Framework The .NET Framework (pronounced as "''dot net"'') is a proprietary software framework developed by Microsoft that runs primarily on Microsoft Windows. It was the predominant implementation of the Common Language Infrastructure (CLI) until bein ...
. The language needed to look and feel like Ruby, and to introduce no new library dependencies into JRuby (which precludes most other
JVM languages This list of JVM Languages comprises notable computer programming languages that are used to produce computer software that runs on the Java virtual machine (JVM). Some of these languages are interpreted by a Java program, and some are compiled ...
) and to suffer no performance penalty (which precludes writing in Ruby). Early versions of Mirah (then Duby) focused mostly on mathematical performance, where
dynamic programming language In computer science, a dynamic programming language is a class of high-level programming languages, which at runtime execute many common programming behaviours that static programming languages perform during compilation. These behaviors cou ...
s often pay the highest cost. Since then it has evolved into a full JVM language, with several users and real-world applications using it for core components.


Design

Mirah is mostly a pluggable compiler toolchain. The main elements of the chain are: # A
parser Parsing, syntax analysis, or syntactic analysis is the process of analyzing a string of symbols, either in natural language, computer languages or data structures, conforming to the rules of a formal grammar. The term ''parsing'' comes from Lati ...
, based on JRuby's parser, that emits a Ruby
abstract syntax tree In computer science, an abstract syntax tree (AST), or just syntax tree, is a tree representation of the abstract syntactic structure of text (often source code) written in a formal language. Each node of the tree denotes a construct occurring ...
(AST) # A transformer that converts the Ruby AST into a Mirah AST # A type inferrer that decorates the Mirah AST with appropriate typing information for the target backend # A backend
code generator In computing, Code generation denotes software techniques or systems that generate program code which may then be used independently of the generator system in a runtime environment. Specific articles: * Code generation (compiler), a mechanism to pr ...
Of these phases, only the last two need specific knowledge of the eventual target platform. This makes Mirah suitable for many backends, and also makes it possible to write language plug-ins for Mirah's transformation phase that will apply to all supported backends equally. For simple pieces of code and the JVM bytecode backend, the Mirah compiler emits nearly the same instructions as standard
javac javac (pronounced "java-see") is the primary Java compiler included in the Java Development Kit (JDK) from Oracle Corporation. Martin Odersky implemented the GJ compiler, and his implementation became the basis for javac. The compiler accepts s ...
compilers.


No runtime library

Because Mirah is just a compiler, it ships no
standard library In computer programming, a standard library is the library made available across implementations of a programming language. These libraries are conventionally described in programming language specifications; however, contents of a language's as ...
. The intent is that Mirah users will choose what libraries they want to use, perhaps write plugins for the Mirah compiler to support them, and the compiler will do the rest. This is an explicit design goal, avoid introducing a requirement on any new external library. The standard library for Mirah, then, is whatever the standard library for the current backend is, and emphasis is placed on writing compiler plugins rather than libraries to extend and enhance the language.


Type system

Mirah does not impose a specific type system on users, instead relying on whatever the target backend provides. On the JVM, the type system is largely Java's type system, and type declarations refer to JVM classes, primitives, and interfaces. Mirah is primarily a statically-typed language, but support is in development to allow dynamic typing also. The mechanism is similar to that provided in C# 4, with a special ''dynamic'' type indicating all dispatches against that
variable Variable may refer to: * Variable (computer science), a symbolic name associated with a value and whose associated value may be changed * Variable (mathematics), a symbol that represents a quantity in a mathematical expression, as used in many ...
's value should be done dynamically. Dynamic type support is currently planned only for
Java 7 The Java language has undergone several changes since JDK 1.0 as well as numerous additions of classes and packages to the standard library. Since J2SE 1.4, the evolution of the Java language has been governed by the Java Community P ...
and higher, using the new invokedynamic bytecode.


Syntax

The syntax of Mirah is largely the same as the syntax of
Ruby A ruby is a pinkish red to blood-red colored gemstone, a variety of the mineral corundum ( aluminium oxide). Ruby is one of the most popular traditional jewelry gems and is very durable. Other varieties of gem-quality corundum are called sa ...
, but with a few modifications to support static typing: * Method parameters usually need to have their types declared: def foo(a:String, b:int) * Because several transformations occur in the Mirah compiler toolchain, some strings that are valid identifiers in Ruby are treated as keywords in Mirah, such as the word interface used to specify a JVM-style interface. Outside of these differences, Mirah code generally looks like Ruby code: def fib(a:int) if a < 2 a else fib(a - 1) + fib(a - 2) end end


Status

, Mirah is under development, but some developers are using Mirah for production
applications Application may refer to: Mathematics and computing * Application software, computer software designed to help the user to perform specific tasks ** Application layer, an abstraction layer that specifies protocols and interface methods used in a c ...
of limited scope.


Frameworks


Dubious

Dubious is a project for running Mirah on
Google App Engine Google App Engine (often referred to as GAE or simply App Engine) is a cloud computing platform as a service for developing and hosting web applications in Google-managed data centers. Applications are sandboxed and run across multiple servers. ...
. It provides a way to build apps in Mirah, with conventions familiar to developers using
Ruby on Rails Ruby on Rails (simplified as Rails) is a server-side web application framework written in Ruby under the MIT License. Rails is a model–view–controller (MVC) framework, providing default structures for a database, a web service, and web p ...
and
Sinatra Francis Albert Sinatra (; December 12, 1915 – May 14, 1998) was an American singer and actor. Nicknamed the "Chairman of the Board" and later called "Ol' Blue Eyes", Sinatra was one of the most popular entertainers of the 1940s, 1950s, and ...
. Since everything is compiled ahead-of-time, Mirah applications have none of the initializing costs associated with JRuby. Dubious supports
ERuby Embedded Ruby (also shortened as ERB) is a templating system that embeds Ruby into a text document. It is often used to embed Ruby code in an HTML document, similar to ASP and JSP, and PHP and other server-side scripting languages. The tem ...
(ERb) and has a simple datastore adapter that uses a syntax similar to
Datamapper In software engineering, the data mapper pattern is an architectural pattern. It was named by Martin Fowler in his 2003 book ''Patterns of Enterprise Application Architecture''. The interface of an object conforming to this pattern would include f ...
.


See also

*
List of JVM languages This list of JVM Languages comprises notable computer programming languages that are used to produce computer software that runs on the Java virtual machine (JVM). Some of these languages are interpreted by a Java program, and some are compiled ...


References


External links

* {{Official website, www.mirah.org
Introduction to Mirah by Charles Nutter
- Dr. Dobb's, March 25, 2011
Breaking the Rules - Making Java Fun with Mirah
- Roja Buck, Mar 20, 2011
A Blend of Java and Ruby - The Mirah Language
- InfoQ, July 27, 2010
Mirah brings Ruby niceties to Java
- InfoWorld. July 23, 2010

- O'Reilly Media, July, 2010
Introducing Duby, Ryan Brown



Dubious framework

Video presentation: JRuby, Duby, and Surinx: Building a Better Ruby

Video Lightning talk: Rails Underground 2009 - Charles Nutter on Charles Nutter - Duby and Juby Languages

What does Mirah offer over JRuby,Groovy and Scala?
JVM programming languages Scripting languages Object-oriented programming languages Java programming language family Software using the Apache license Programming languages created in 2008